// 防抖
export function debounce(fn) {
    let time = null

    return function () {
        if (time !== null) {
            clearTimeout(time)
        }
        time = setTimeout(() => {
            fn()
        }, 200);
    }
}
// 滚动到顶部
export function toTop() {
    let topTime
    if (topTime == null) {
        let top = document.documentElement.scrollTop || document.body.scrollTop
        topTime = setInterval(() => {
            document.documentElement.scrollTop = top -= 50
            if (document.documentElement.scrollTop <= 0) {
                clearInterval(topTime)
                topTime = null
            }
        }, 10)
    }
}